/*
 * @Descripttion: |
 * @version: 1.0
 * @Author: 王娆
 * @Date: 2020-08-23 17:35:04
 * @LastEditors: 王娆
 * @LastEditTime: 2020-08-26 21:39:55
 */
import router from '../../router'
import homeRoutes from '../../router/homeRoutes/homeRoutes' 
import filterRouter from '../../utils/filterRoutes'
const state={
    filterRouter:[]
}

const mutations={
    setFilterRouter(state,payload){
        state.filterRouter = payload
    }
}

const actions= {
    getRoutes({commit},userInfo){
        let res = filterRouter(homeRoutes,userInfo)
        console.log(res)
        router.addRoutes(res)
        sessionStorage.setItem('filterRouter',JSON.stringify(res))
        commit('setFilterRouter',res)
        res.length && router.push(res[0].path)
    }
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}
